from django.db import models
from apps.common.base.models import BaseModel
from apps.system.payway.models import Payway
from apps.system.lessee.models import Lessee
from  apps.user.models import UserModel

class RecordIncomesLocked(BaseModel):
    payway = (
        ('wxpay', "微信支付"),
        ('alipay', "支付宝支付"),
        ('incomeAndIncomeLocked', "积分组合支付"),
        ('incomes', "积分支付"),
        ('incomesLocked', "专项积分支付"),
        ('golds', "金币支付"),
    )
    scene = (
        ('goldCustom', "购买黄金定制"),
        ('expense', "消费"),
    )
    orderStatus = (
        ("LOCKED", "锁定中"),
        ('UNLOCKED', "已解锁"),
        ('FINISH', "已处置")
    )
    # 资产处置类型
    handleType = (
        ('1', "到期发货"),
        ('2', "订单转让"),
        ('3', "退货退款"),
    )
    lessee = models.ForeignKey(Lessee, related_name="lessee_recordIncomesLocked", verbose_name='租户',
                               on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    scene = models.CharField("收支类型", max_length=100, choices=scene, blank=True, null=True)
    user = models.ForeignKey(UserModel, related_name='user_recordIncomesLocked', verbose_name='用户', on_delete=models.SET_NULL,
                             null=True, blank=True, db_constraint=False)
    fromUser = models.ForeignKey(UserModel, related_name='from_recordIncomesLocked', verbose_name='来自用户',
                                 on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    payWayAccount = models.ForeignKey(Payway, related_name='payWayAccount_recordIncomesLocked', verbose_name='收款账户',
                                      on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    orderId = models.CharField('订单ID', max_length=100, blank=True)
    money = models.DecimalField("锁仓金额1", max_digits=10, decimal_places=2, default=0)
    money2 = models.DecimalField("锁仓金额2", max_digits=10, decimal_places=2, default=0)
    balanceIncomes = models.DecimalField("余额积分", max_digits=10, decimal_places=2, default=0)
    serviceCharge = models.DecimalField("服务费", max_digits=10, decimal_places=2, default=0)
    realMoney = models.DecimalField("实际到账", max_digits=10, decimal_places=2, default=0)
    outMoneyTime = models.DateTimeField('处理日期', null=True, blank=True)
    payway = models.CharField("付款类型", choices=payway, max_length=100, blank=True, null=True)
    changeWay = models.CharField("变动方向", max_length=200, blank=True, null=True, default='')  # 增加/减少
    orderStatus = models.CharField("记录状态", max_length=100, choices=orderStatus, default="LOCKED")
    remark = models.CharField('备注', max_length=200, blank=True, default='')
    unlockedTime = models.DateTimeField('解锁日期', null=True, blank=True)
    handleType = models.CharField("资产处置类型", max_length=100, choices=handleType, blank=True, null=True)

    class Meta:
        verbose_name = 'RecordIncomesLocked'
        verbose_name_plural = verbose_name
